FROM {{ namespace }}/{{ image_prefix }}masakari-base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block masakari_monitors_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{{ macros.enable_extra_repos(['hacluster']) }}

{% if base_package_type == 'rpm' %}

    {% set masakari_monitors_packages = [
        'cyrus-sasl-md5',
        'cyrus-sasl-scram',
        'python3-libvirt',
        'pacemaker-cli',
        'tcpdump',
    ] %}

{% elif base_package_type == 'deb' %}

    {% set masakari_monitors_packages = [
        'libsasl2-modules-gssapi-mit',
        'python3-libvirt',
        'pacemaker-cli-utils',
        'sasl2-bin',
        'tcpdump',
    ] %}

{% endif %}

{{ macros.install_packages(masakari_monitors_packages | customizable("packages")) }}

ADD masakari-monitors-archive /masakari-monitors-source

{% set masakari_monitors_pip_packages = [
    '/masakari-monitors'
] %}

COPY masakari_monitors_sudoers /etc/sudoers.d/kolla_masakari_monitors_sudoers

RUN ln -s masakari-monitors-source/* masakari-monitors \
    && {{ macros.install_pip(masakari_monitors_pip_packages | customizable("pip_packages")) }} \
    && mkdir -p /etc/masakari-monitors \
    && chmod 750 /etc/sudoers.d \
    && chmod 640 /etc/sudoers.d/kolla_masakari_monitors_sudoers

{{ macros.kolla_patch_sources() }}

{% block masakari_monitors_footer %}{% endblock %}
{% block footer %}{% endblock %}

USER masakari
